﻿using MengLin.OOP.DesignPattern.CommandPattern.Barbecuer.Abstract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MengLin.OOP.DesignPattern.CommandPattern.Barbecuer
{
    /// <summary>
    /// 服务员
    /// </summary>
    public class Waiter
    {
        private IList<AbstractCommand> _orders = new List<AbstractCommand>();

        /// <summary>
        /// 设置订单
        /// </summary>
        /// <param name="command"></param>
        public void SetOrder(AbstractCommand command)
        {
            if (command.ToString() == "命令模式.BakeChickenWingCommand")
            {
                Console.WriteLine("服务员：鸡翅没有了，请点别的烧烤。");
            }
            else
            {
                _orders.Add(command);
                Console.WriteLine("增加订单：" + command.ToString() + "  时间：" + DateTime.Now.ToString());
            }
        }

        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="command"></param>
        public void CancelOrder(AbstractCommand command)
        {
            _orders.Remove(command);
            Console.WriteLine("取消订单：" + command.ToString() + "  时间：" + DateTime.Now.ToString());
        }

        /// <summary>
        /// 通知全部执行
        /// </summary>
        public void Notify()
        {
            foreach (AbstractCommand command in _orders)
            {
                command.ExcuteCommand();
            }

            //通知执行
            //command.ExcuteCommand();
        }
    }
}
